Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The opener npm package is a utility that allows you to open files, URLs, executables, and directories with their default application from Node.js. It is a cross-platform package that works on Windows, macOS, and Linux.
Open URLs in the default web browser
This feature allows you to open a URL in the user's default web browser. It is useful for redirecting users to web pages from a Node.js application.
const opener = require('opener');
opener('http://www.google.com');
Open files in the default application
This feature enables you to open a file with its associated default application. For example, a PDF would be opened in a PDF viewer.
const opener = require('opener');
opener('path/to/file.pdf');
Open directories in the default file explorer
With this feature, you can open a directory in the system's default file explorer, which can be handy for showing users where certain files are located.
const opener = require('opener');
opener('path/to/directory/');
The 'open' package is similar to 'opener' and is used to open files, URLs, and executables across different platforms. It provides more options and greater control over how the resources are opened, such as specifying the application to use.
While 'execa' is not a direct alternative to 'opener', it is a process execution tool that can be used to open applications and resources by running system commands. It provides a more programmatic approach to handling system processes.
The 'child_process' module is built into Node.js and can be used to achieve similar results as 'opener' by spawning system processes. It requires more setup and understanding of system commands but is very powerful and flexible.
That is, in your desktop environment. This will make actual windows pop up, with stuff in them:
npm install opener -g
opener http://google.com
opener ./my-file.txt
opener firefox
opener npm run lint
Also if you want to use it programmatically you can do that too:
var opener = require("opener");
opener("http://google.com");
opener("./my-file.txt");
opener("firefox");
opener("npm run lint");
Plus, it returns the child process created, so you can do things like let your script exit while the window stays open:
var editor = opener("documentation.odt");
editor.unref();
// These other unrefs may be necessary if your OS's opener process
// exits before the process it started is complete.
editor.stdin.unref();
editor.stdout.unref();
editor.stderr.unref();
Like opening the user's browser with a test harness in your package's test script:
{
"scripts": {
"test": "opener ./test/runner.html"
},
"devDependencies": {
"opener": "*"
}
}
Because Windows has start
, Macs have open
, and *nix has xdg-open
. At least according to some person on StackOverflow. And I like things that work on all three. Like Node.js. And Opener.
FAQs
Opens stuff, like webpages and files and executables, cross-platform
The npm package opener receives a total of 5,450,308 weekly downloads. As such, opener popularity was classified as popular.
We found that opener demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.